package example.plugins.automaton;

import framework.automaton.State;

/**
 * In this example plugin that creates Conway's Game of Life, this class is the
 * concrete State class, defining the states used in the game. In this example,
 * the two states, dead and alive, are represented by integers (see Constants).
 * @author May
 *
 */
public class ConwayState implements State{
	/**state is defined by an int*/
	private int currentState;

	/**
	 * Construct a new state
	 * @param state integer representing current state
	 */
	public ConwayState(int state){
		currentState = state;
	}

	/**
	 * @return the integer representing the state
	 */
	public int getCurrentState(){
		return currentState;
	}

	public String toString(){
		return "" + currentState;
	}

	/**
	 * Checks to see if two ConwayState objects are equal
	 * @param arg0 ConwayState object to be compared to
	 * @return true if they are the same state (same integer)
	 */
	public boolean equals(Object arg0){
		ConwayState temp = (ConwayState)arg0;
		if(temp.currentState-this.currentState==0){
			return true;
		}
		return false;
	}

	/**
	 * Since we defined each state (alive and dead) in the example to be
	 * be represented by a unique integer, that become the hashcode for the State
	 * @return hashCode unique identifier of the current state
	 */
	public int hashCode(){
		return currentState;
	}
}
